package com.yehongyu.mytools.database.connectdb;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectToSQL {

	public ConnectToSQL() {
		super();
	}

	/**
	 * @param args
	 * @throws SDBException 
	 */
	public static void main(String[] args) {
		
		//Connection con = DBConnectionPool.getConnection("mssql");
		Connection conms = null;
		try {
			Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver")
					.newInstance();
			String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=egov";
			// egov为数据库
			String user = "sa";
			String password = "sa";
			conms = DriverManager.getConnection(url, user, password);
			conms.close();
		} catch (InstantiationException e1) {
			e1.printStackTrace();
		} catch (IllegalAccessException e1) {
			e1.printStackTrace();
		} catch (ClassNotFoundException e1) {
			e1.printStackTrace();
		} catch (SQLException e1) {
			e1.printStackTrace();
		} 
		if (conms==null){
			System.out.println(":-( mssql连接失败");
		}else System.out.println(":-) mssql连接成功");

		
       
    	
	}

}
